package com.lark.web.xterm.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import com.lark.web.xterm.handler.WebSSHWebSocketHandler;

@Configuration
@EnableWebSocket
public class WSConfig implements org.springframework.web.socket.config.annotation.WebSocketConfigurer {

    @Autowired
    WebSSHWebSocketHandler webSSHWebSocketHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(webSSHWebSocketHandler, "/wsh")
               .setAllowedOrigins("*")
               .addInterceptors(new QueryParamHandshakeInterceptor());
    }
}